/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bankapp.model;

import bankapp.controller.AddInterestController;
import bankapp.view.BankTableModel;
import bankapp.view.BankUITopPanel;
import framework.controller.IController;
import framework.model.Account;
import framework.model.Constant;
import framework.model.Customer;
import framework.model.Factory;
import framework.view.AddCompanyAccountDialog;
import framework.view.AddPersonalAccountDialog;
import framework.view.TopPanel;
import java.util.HashMap;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author ThanhNguyen
 */
public class BankFactory extends Factory {

    @Override
    public TopPanel createTopPanel() {
        return new BankUITopPanel();
    }

    public IController createAddInterestController() {
        return new AddInterestController();
    }

    @Override
    public AddPersonalAccountDialog createAddPersonalAccountDialog() {
        return new bankapp.view.AddPersonalBankAccountDialog();
    }

    @Override
    public AddCompanyAccountDialog createAddCompanyAccountDialog() {
        return new bankapp.view.AddCompanyBankAccountDialog();
    }

    @Override
    public Account createAccount(Customer cust, HashMap<String, String> fields) {
        if (fields.get(Constant.BANK_ACCOUNT_TYPE).equals(Constant.BANK_TYPE_SAVING)) {
            return new SavingAccount(cust);
        } else {
            return new CheckingAccount(cust);
        }
    }

    @Override
    public AbstractTableModel createAccountTableModel() {
        return new BankTableModel();
    }
}
